package sunbt.gistools.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import sunbt.gistools.exception.enums.ErrorCodeEnum;

/**
 * 业务逻辑异常
 *
 * @author huangsh
 * @since 2024/08/19
 */
@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class BusinessException extends RuntimeException {

    /**
     * 业务错误码
     *
     * @see ErrorCodeEnum
     */
    private Integer code;
    /**
     * 错误提示
     */
    private String message;

    public BusinessException(String message) {
        this.code = ErrorCodeEnum.BUSINESS_ERROR.getCode();
        this.message = message;
    }

    public BusinessException(ErrorCodeEnum errorCodeEnum) {
        this.code = errorCodeEnum.getCode();
        this.message = errorCodeEnum.getMsg();
    }

}
